package Service.Student.Imp;

import Dao.DaoFactory;
import Dao.Role.StuInfoDao;
import Dao.Student.StudentDao;
import Entity.Grade.Score;
import Entity.Role.Student;
import Entity.Student.StuInfo;
import Service.Student.HomeService;
import Util.DBUtil;

import java.sql.Connection;
import java.util.List;

public class HomeServiceImp implements HomeService {
    private StudentDao studentDao;
    private StuInfoDao stuInfoDao;
    private Connection conn;

    public HomeServiceImp() {
        conn = DBUtil.getConnByDruid();
        studentDao = DaoFactory.getInstance("studentDao");
        stuInfoDao = DaoFactory.getInstance("stuInfoDao");
    }

    @Override
    public Student getStuInfo(String sno) {
        Student stuInfo = stuInfoDao.getStuByNO(sno, conn).get(0);
        DBUtil.closeConn(conn);
        return stuInfo;
    }

    @Override
    public List<Score> getStuScore(String sno) {
        List<Score> scores = studentDao.getStuScore(sno, conn);
        DBUtil.closeConn(conn);
        return scores;
    }

}
